package com.one.consumer.user.ui;

import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.one.common.config.MyContact;
import com.one.common.config.RouterPath;
import com.one.common.utils.SystemUtils;
import com.one.common.view.widget.InputLayout;
import com.one.common.view.widget.MyTitleBar;
import com.one.consumer.BaseActivityC;
import com.one.consumer.R;
import com.one.consumer.user.model.item.InvoiceItem;
import com.one.consumer.user.presenter.InvoiceDetailPresenter;
import com.one.consumer.user.ui.view.InvoiceView;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/11/4 9:39 PM
 * description ：发票详情页
 **/
@Route(path = RouterPath.INVOICE_DETAIL)
public class InvoiceDetailActivity extends BaseActivityC<InvoiceDetailPresenter> implements InvoiceView {
    @BindView(R.id.tv_time)
    TextView tvTime;
    @BindView(R.id.tv_order_no)
    TextView tvOrderNo;
    @BindView(R.id.il_invoice_look_up)
    InputLayout ilInvoiceLookUp;
    @BindView(R.id.il_invoice_no)
    InputLayout ilInvoiceNo;
    @BindView(R.id.il_invoice_content)
    InputLayout ilInvoiceContent;
    @BindView(R.id.il_invoice_money)
    InputLayout ilInvoiceMoney;
    @BindView(R.id.il_invoice_time)
    InputLayout ilInvoiceTime;
    @BindView(R.id.il_invoice_contact)
    InputLayout ilInvoiceContact;
    @BindView(R.id.il_invoice_contact_phone)
    InputLayout ilInvoiceContactPhone;
    @BindView(R.id.il_invoice_contact_address)
    InputLayout ilInvoiceContactAddress;
    @BindView(R.id.il_invoice_logistics)
    InputLayout ilInvoiceLogistics;
    @BindView(R.id.il_invoice_logistics_no)
    InputLayout ilInvoiceLogisticsNo;
    @BindView(R.id.tv_kefu)
    TextView tvKefu;
    @BindView(R.id.tv_type)
    TextView tvType;

    @Override
    protected void initPresenter() {
        mPresenter = new InvoiceDetailPresenter(this, this);
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_invoice_detail;
    }


    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("开票详情");
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.getDetail();
    }

    @Override
    public void setDetail(InvoiceItem item) {
        tvType.setText(item.getInvoice_class() + item.getInvoice_state());
        tvTime.setText(item.getUpdate_time());
        tvOrderNo.setText(item.getOrder_no());
        if (item.getInvoice_type().equals("1")) {
            ilInvoiceLookUp.setText(item.getInvoice_name());
        } else {
            ilInvoiceLookUp.setText(item.getInvoice_company_name());
        }
        ilInvoiceNo.setText(item.getInvoice_no());
        ilInvoiceContact.setText("技术费");
        ilInvoiceMoney.setText(item.getOrder_price());
        ilInvoiceTime.setText(item.getCreate_time());
        ilInvoiceContact.setText(item.getInvoice_member());
        ilInvoiceContactPhone.setText(item.getInvoice_member_phone());
        ilInvoiceContactAddress.setText(item.getInvoice_member_address());
        ilInvoiceLogistics.setText(item.getCourier_company());
        ilInvoiceLogisticsNo.setText(item.getCourier_number());
    }

    @OnClick(R.id.tv_kefu)
    public void callkefu(){
        SystemUtils.call(this, MyContact.PHONE_KEFU);
    }


}
